package CoteClient;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JPasswordField;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.SwingConstants;
import javax.swing.JTextField;

public class VueModifierMdp extends Vue {
	private JPasswordField txtAncien;
	private JPasswordField txtNouveau;
	private JPasswordField txtRepete;

	public VueModifierMdp(Controleur controleur){
		super(controleur);
		setTitle("Modifier mot de passe");
		getContentPane().setLayout(null);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 352, 167);
		
		JLabel lblAncienMotDe = new JLabel("Ancien mot de passe");
		lblAncienMotDe.setHorizontalAlignment(SwingConstants.RIGHT);
		lblAncienMotDe.setBounds(35, 12, 140, 15);
		getContentPane().add(lblAncienMotDe);
		
		JLabel lblNouveauMotDe = new JLabel("Nouveau mot de passe");
		lblNouveauMotDe.setHorizontalAlignment(SwingConstants.RIGHT);
		lblNouveauMotDe.setBounds(22, 39, 153, 15);
		getContentPane().add(lblNouveauMotDe);
		
		JLabel lblRptezMotDe = new JLabel("Répétez mot de passe");
		lblRptezMotDe.setHorizontalAlignment(SwingConstants.RIGHT);
		lblRptezMotDe.setBounds(22, 66, 153, 15);
		getContentPane().add(lblRptezMotDe);
		
		txtAncien = new JPasswordField();
		txtAncien.setBounds(193, 10, 114, 19);
		getContentPane().add(txtAncien);
		txtAncien.setColumns(10);
		
		txtNouveau = new JPasswordField();
		txtNouveau.setBounds(193, 37, 114, 19);
		getContentPane().add(txtNouveau);
		txtNouveau.setColumns(10);
		
		txtRepete = new JPasswordField();
		txtRepete.setBounds(193, 64, 114, 19);
		getContentPane().add(txtRepete);
		txtRepete.setColumns(10);
		
		JButton btnAnnuler = new JButton("Annuler");
		btnAnnuler.setBounds(200, 93, 107, 25);
		btnAnnuler.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			getControleur().lancerMenu();
			}
		});
		getContentPane().add(btnAnnuler);
		
		JButton btnModifier = new JButton("Modifier");
		btnModifier.setBounds(68, 93, 107, 25);
		btnModifier.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				getControleur().modifierMdp(txtAncien.getText(), txtNouveau.getText(), txtRepete.getText());
			}
		});
		getContentPane().add(btnModifier);
	}
}
